home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / javaString.h < prev    next >
C/C++ Source or Header  |  1998-09-15  |  3KB  |  109 lines

  1. /*
  2.  * @(#)javaString.h    1.16 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. /*
  16.  * Java string utilities
  17.  */
  18.  
  19. #ifndef _JAVASTRING_H_
  20. #define _JAVASTRING_H_
  21.  
  22. #include "oobj.h"
  23.  
  24. #include "java_lang_String.h"
  25.  
  26.  
  27. /*
  28.  * Print the String object with prints.
  29.  */
  30. void javaStringPrint(Hjava_lang_String *);
  31.  
  32. /*
  33.  * Return the length of the String object.
  34.  */
  35. int javaStringLength(Hjava_lang_String *);
  36.  
  37.  
  38. /*
  39.  * Create and return a new Java String object, initialized from the C string.
  40.  */
  41. Hjava_lang_String *makeJavaString(char *, int);
  42.  
  43. /*
  44.  * Create a new C string initialized from the specified Java string,
  45.  * and return a pointer to it.
  46.  * For makeCString, temporary storage is allocated and released automatically
  47.  * when all references to the returned value are eliminated. WARNING: You 
  48.  * must keep this pointer in a variable to prevent the storage from getting
  49.  * garbage collected.
  50.  * For allocCString, a "malloc" is used to get the storage; the caller is
  51.  * responsible for "free"ing the pointer that is returned.
  52.  * 
  53.  */
  54. char *makeCString(Hjava_lang_String *s);
  55. char *allocCString(Hjava_lang_String *s);
  56.  
  57. /*
  58.  * Get the characters of the String object into a unicode string buffer.
  59.  * No allocation occurs. Assumes that len is less than or equal to
  60.  * the length of the string, and that the buf is at least len+1 unicodes
  61.  * in size. The unicode buffer's address is returned.
  62.  */
  63. unicode *javaString2unicode(Hjava_lang_String *, unicode *, int);
  64.  
  65. /*
  66.  * Get the characters of the String object into a C string buffer.
  67.  * No allocation occurs. Assumes that len is the size of the buffer.
  68.  * The C string's address is returned.
  69.  */
  70. char *javaString2CString(Hjava_lang_String *, char *, int);
  71.  
  72. /*
  73.  * convert Java String to platform encoding string.
  74.  */
  75. char *makePlatformCString(Hjava_lang_String *);
  76.  
  77. /*
  78.  * convert platform encoding string to Java String.
  79.  */
  80. Hjava_lang_String *makeJavaStringFromPlatformCString(char *, int);
  81.  
  82. /*
  83.  * Returns the number of bytes needed to hold a Java string in UTF
  84.  * format, NOT including the terminating NULL.
  85.  *
  86.  * Returns -1 if something is wrong.
  87.  */
  88. int
  89. javaStringUTFLength(HString *s);
  90.  
  91. /*
  92.  * Fill buf with unicode representation of hstr, upto buflen chars.
  93.  * The UTF string will be NUL-terminated.
  94.  *
  95.  * If both buf and buflen are 0, malloc an appropriately sized
  96.  * buffer for the result.
  97.  *
  98.  * Return result buffer.
  99.  */
  100. char *javaString2UTF(HString *, char *, int);
  101.  
  102. /*
  103.  * Create a Java String whose characters are initialized from
  104.  * the supplied NUL-terminated UTF string.
  105.  */
  106. HString *makeJavaStringUTF(char *);
  107.  
  108. #endif /* !_JAVASTRING_H_ */
  109.